﻿''' <summary>
''' Tracks the state of each key on the keyboard.
''' </summary>
''' <remarks></remarks>
Public Structure KeyboardStateInfo
    Private None As Boolean
    Private LButton As Boolean
    Private RButton As Boolean
    Private Cancel As Boolean
    Private MButton As Boolean
    Private XButton1 As Boolean
    Private XButton2 As Boolean
    Private Back As Boolean
    Private Tab As Boolean
    Private LineFeed As Boolean
    Private Clear As Boolean
    Private Enter As Boolean
    Private [Return] As Boolean
    Private ShiftKey As Boolean
    Private ControlKey As Boolean
    Private Menu As Boolean
    Private Pause As Boolean
    Private CapsLock As Boolean
    Private Capital As Boolean
    Private HangulMode As Boolean
    Private HanguelMode As Boolean
    Private KanaMode As Boolean
    Private JunjaMode As Boolean
    Private FinalMode As Boolean
    Private KanjiMode As Boolean
    Private HanjaMode As Boolean
    Private Escape As Boolean
    Private IMEConvert As Boolean
    Private IMENonconvert As Boolean
    Private IMEAccept As Boolean
    Private IMEAceept As Boolean
    Private IMEModeChange As Boolean
    Private Space As Boolean
    Private Prior As Boolean
    Private PageUp As Boolean
    Private PageDown As Boolean
    Private [Next] As Boolean
    Private [End] As Boolean
    Private Home As Boolean
    Private Left As Boolean
    Private Up As Boolean
    Private Right As Boolean
    Private Down As Boolean
    Private [Select] As Boolean
    Private Print As Boolean
    Private Execute As Boolean
    Private Snapshot As Boolean
    Private PrintScreen As Boolean
    Private Insert As Boolean
    Private Delete As Boolean
    Private Help As Boolean
    Private D0 As Boolean
    Private D1 As Boolean
    Private D2 As Boolean
    Private D3 As Boolean
    Private D4 As Boolean
    Private D5 As Boolean
    Private D6 As Boolean
    Private D7 As Boolean
    Private D8 As Boolean
    Private D9 As Boolean
    Private A As Boolean
    Private B As Boolean
    Private C As Boolean
    Private D As Boolean
    Private E As Boolean
    Private F As Boolean
    Private G As Boolean
    Private H As Boolean
    Private I As Boolean
    Private J As Boolean
    Private K As Boolean
    Private L As Boolean
    Private M As Boolean
    Private N As Boolean
    Private O As Boolean
    Private P As Boolean
    Private Q As Boolean
    Private R As Boolean
    Private S As Boolean
    Private T As Boolean
    Private U As Boolean
    Private V As Boolean
    Private W As Boolean
    Private X As Boolean
    Private Y As Boolean
    Private Z As Boolean
    Private LWin As Boolean
    Private RWin As Boolean
    Private Apps As Boolean
    Private Sleep As Boolean
    Private NumPad0 As Boolean
    Private NumPad1 As Boolean
    Private NumPad2 As Boolean
    Private NumPad3 As Boolean
    Private NumPad4 As Boolean
    Private NumPad5 As Boolean
    Private NumPad6 As Boolean
    Private NumPad7 As Boolean
    Private NumPad8 As Boolean
    Private NumPad9 As Boolean
    Private Multiply As Boolean
    Private Add As Boolean
    Private Separator As Boolean
    Private Subtract As Boolean
    Private [Decimal] As Boolean
    Private Divide As Boolean
    Private F1 As Boolean
    Private F2 As Boolean
    Private F3 As Boolean
    Private F4 As Boolean
    Private F5 As Boolean
    Private F6 As Boolean
    Private F7 As Boolean
    Private F8 As Boolean
    Private F9 As Boolean
    Private F10 As Boolean
    Private F11 As Boolean
    Private F12 As Boolean
    Private F13 As Boolean
    Private F14 As Boolean
    Private F15 As Boolean
    Private F16 As Boolean
    Private F17 As Boolean
    Private F18 As Boolean
    Private F19 As Boolean
    Private F20 As Boolean
    Private F21 As Boolean
    Private F22 As Boolean
    Private F23 As Boolean
    Private F24 As Boolean
    Private NumLock As Boolean
    Private Scroll As Boolean
    Private LShiftKey As Boolean
    Private RShiftKey As Boolean
    Private LControlKey As Boolean
    Private RControlKey As Boolean
    Private LMenu As Boolean
    Private RMenu As Boolean
    Private BrowserBack As Boolean
    Private BrowserForward As Boolean
    Private BrowserRefresh As Boolean
    Private BrowserStop As Boolean
    Private BrowserSearch As Boolean
    Private BrowserFavorites As Boolean
    Private BrowserHome As Boolean
    Private VolumeMute As Boolean
    Private VolumeDown As Boolean
    Private VolumeUp As Boolean
    Private MediaNextTrack As Boolean
    Private MediaPreviousTrack As Boolean
    Private MediaStop As Boolean
    Private MediaPlayPause As Boolean
    Private LaunchMail As Boolean
    Private SelectMedia As Boolean
    Private LaunchApplication1 As Boolean
    Private LaunchApplication2 As Boolean
    Private OemSemicolon As Boolean
    Private Oem1 As Boolean
    Private Oemplus As Boolean
    Private Oemcomma As Boolean
    Private OemMinus As Boolean
    Private OemPeriod As Boolean
    Private Oem2 As Boolean
    Private OemQuestion As Boolean
    Private Oem3 As Boolean
    Private Oemtilde As Boolean
    Private Oem4 As Boolean
    Private OemOpenBrackets As Boolean
    Private OemPipe As Boolean
    Private Oem5 As Boolean
    Private OemCloseBrackets As Boolean
    Private Oem6 As Boolean
    Private OemQuotes As Boolean
    Private Oem7 As Boolean
    Private Oem8 As Boolean
    Private Oem102 As Boolean
    Private OemBackslash As Boolean
    Private ProcessKey As Boolean
    Private Packet As Boolean
    Private Attn As Boolean
    Private Crsel As Boolean
    Private Exsel As Boolean
    Private EraseEof As Boolean
    Private Play As Boolean
    Private Zoom As Boolean
    Private NoName As Boolean
    Private Pa1 As Boolean
    Private OemClear As Boolean
    Private KeyCode As Boolean
    Private Shift As Boolean
    Private Control As Boolean
    Private Alt As Boolean
    Private Modifiers As Boolean

    ''' <summary>
    ''' Gets the pressed-state for the specified keyboard key.
    ''' </summary>
    ''' <param name="key">The keyboard key whose state should be returned.</param>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Default Public ReadOnly Property Item(ByVal key As Keys) As Boolean
        Get
            Dim field As System.Reflection.FieldInfo
            field = Me.GetType.GetField([Enum].GetName(GetType(Keys), key), Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
            Return CBool(field.GetValue(Me))
        End Get
    End Property

    Friend Sub SetKey(ByVal key As Keys, ByVal value As Boolean)
        Select Case key
            Case Keys.None
                None = value
            Case Keys.LButton
                LButton = value
            Case Keys.RButton
                RButton = value
            Case Keys.Cancel
                Cancel = value
            Case Keys.MButton
                MButton = value
            Case Keys.XButton1
                XButton1 = value
            Case Keys.XButton2
                XButton2 = value
            Case Keys.Back
                Back = value
            Case Keys.Tab
                Tab = value
            Case Keys.LineFeed
                LineFeed = value
            Case Keys.Clear
                Clear = value
            Case Keys.Enter
                Enter = value
            Case Keys.Return
                [Return] = value
            Case Keys.ShiftKey
                ShiftKey = value
            Case Keys.ControlKey
                ControlKey = value
            Case Keys.Menu
                Menu = value
            Case Keys.Pause
                Pause = value
            Case Keys.CapsLock
                CapsLock = value
            Case Keys.Capital
                Capital = value
            Case Keys.HangulMode
                HangulMode = value
            Case Keys.HanguelMode
                HanguelMode = value
            Case Keys.KanaMode
                KanaMode = value
            Case Keys.JunjaMode
                JunjaMode = value
            Case Keys.FinalMode
                FinalMode = value
            Case Keys.KanjiMode
                KanjiMode = value
            Case Keys.HanjaMode
                HanjaMode = value
            Case Keys.Escape
                Escape = value
            Case Keys.IMEConvert
                IMEConvert = value
            Case Keys.IMENonconvert
                IMENonconvert = value
            Case Keys.IMEAccept
                IMEAccept = value
            Case Keys.IMEAceept
                IMEAceept = value
            Case Keys.IMEModeChange
                IMEModeChange = value
            Case Keys.Space
                Space = value
            Case Keys.Prior
                Prior = value
            Case Keys.PageUp
                PageUp = value
            Case Keys.PageDown
                PageDown = value
            Case Keys.Next
                [Next] = value
            Case Keys.End
                [End] = value
            Case Keys.Home
                Home = value
            Case Keys.Left
                Left = value
            Case Keys.Up
                Up = value
            Case Keys.Right
                Right = value
            Case Keys.Down
                Down = value
            Case Keys.Select
                [Select] = value
            Case Keys.Print
                Print = value
            Case Keys.Execute
                Execute = value
            Case Keys.Snapshot
                Snapshot = value
            Case Keys.PrintScreen
                PrintScreen = value
            Case Keys.Insert
                Insert = value
            Case Keys.Delete
                Delete = value
            Case Keys.Help
                Help = value
            Case Keys.D0
                D0 = value
            Case Keys.D1
                D1 = value
            Case Keys.D2
                D2 = value
            Case Keys.D3
                D3 = value
            Case Keys.D4
                D4 = value
            Case Keys.D5
                D5 = value
            Case Keys.D6
                D6 = value
            Case Keys.D7
                D7 = value
            Case Keys.D8
                D8 = value
            Case Keys.D9
                D9 = value
            Case Keys.A
                A = value
            Case Keys.B
                B = value
            Case Keys.C
                C = value
            Case Keys.D
                D = value
            Case Keys.E
                E = value
            Case Keys.F
                F = value
            Case Keys.G
                G = value
            Case Keys.H
                H = value
            Case Keys.I
                I = value
            Case Keys.J
                J = value
            Case Keys.K
                K = value
            Case Keys.L
                L = value
            Case Keys.M
                M = value
            Case Keys.N
                N = value
            Case Keys.O
                O = value
            Case Keys.P
                P = value
            Case Keys.Q
                Q = value
            Case Keys.R
                R = value
            Case Keys.S
                S = value
            Case Keys.T
                T = value
            Case Keys.U
                U = value
            Case Keys.V
                V = value
            Case Keys.W
                W = value
            Case Keys.X
                X = value
            Case Keys.Y
                Y = value
            Case Keys.Z
                Z = value
            Case Keys.LWin
                LWin = value
            Case Keys.RWin
                RWin = value
            Case Keys.Apps
                Apps = value
            Case Keys.Sleep
                Sleep = value
            Case Keys.NumPad0
                NumPad0 = value
            Case Keys.NumPad1
                NumPad1 = value
            Case Keys.NumPad2
                NumPad2 = value
            Case Keys.NumPad3
                NumPad3 = value
            Case Keys.NumPad4
                NumPad4 = value
            Case Keys.NumPad5
                NumPad5 = value
            Case Keys.NumPad6
                NumPad6 = value
            Case Keys.NumPad7
                NumPad7 = value
            Case Keys.NumPad8
                NumPad8 = value
            Case Keys.NumPad9
                NumPad9 = value
            Case Keys.Multiply
                Multiply = value
            Case Keys.Add
                Add = value
            Case Keys.Separator
                Separator = value
            Case Keys.Subtract
                Subtract = value
            Case Keys.Decimal
                [Decimal] = value
            Case Keys.Divide
                Divide = value
            Case Keys.F1
                F1 = value
            Case Keys.F2
                F2 = value
            Case Keys.F3
                F3 = value
            Case Keys.F4
                F4 = value
            Case Keys.F5
                F5 = value
            Case Keys.F6
                F6 = value
            Case Keys.F7
                F7 = value
            Case Keys.F8
                F8 = value
            Case Keys.F9
                F9 = value
            Case Keys.F10
                F10 = value
            Case Keys.F11
                F11 = value
            Case Keys.F12
                F12 = value
            Case Keys.F13
                F13 = value
            Case Keys.F14
                F14 = value
            Case Keys.F15
                F15 = value
            Case Keys.F16
                F16 = value
            Case Keys.F17
                F17 = value
            Case Keys.F18
                F18 = value
            Case Keys.F19
                F19 = value
            Case Keys.F20
                F20 = value
            Case Keys.F21
                F21 = value
            Case Keys.F22
                F22 = value
            Case Keys.F23
                F23 = value
            Case Keys.F24
                F24 = value
            Case Keys.NumLock
                NumLock = value
            Case Keys.Scroll
                Scroll = value
            Case Keys.LShiftKey
                LShiftKey = value
            Case Keys.RShiftKey
                RShiftKey = value
            Case Keys.LControlKey
                LControlKey = value
            Case Keys.RControlKey
                RControlKey = value
            Case Keys.LMenu
                LMenu = value
            Case Keys.RMenu
                RMenu = value
            Case Keys.BrowserBack
                BrowserBack = value
            Case Keys.BrowserForward
                BrowserForward = value
            Case Keys.BrowserRefresh
                BrowserRefresh = value
            Case Keys.BrowserStop
                BrowserStop = value
            Case Keys.BrowserSearch
                BrowserSearch = value
            Case Keys.BrowserFavorites
                BrowserFavorites = value
            Case Keys.BrowserHome
                BrowserHome = value
            Case Keys.VolumeMute
                VolumeMute = value
            Case Keys.VolumeDown
                VolumeDown = value
            Case Keys.VolumeUp
                VolumeUp = value
            Case Keys.MediaNextTrack
                MediaNextTrack = value
            Case Keys.MediaPreviousTrack
                MediaPreviousTrack = value
            Case Keys.MediaStop
                MediaStop = value
            Case Keys.MediaPlayPause
                MediaPlayPause = value
            Case Keys.LaunchMail
                LaunchMail = value
            Case Keys.SelectMedia
                SelectMedia = value
            Case Keys.LaunchApplication1
                LaunchApplication1 = value
            Case Keys.LaunchApplication2
                LaunchApplication2 = value
            Case Keys.OemSemicolon
                OemSemicolon = value
            Case Keys.Oem1
                Oem1 = value
            Case Keys.Oemplus
                Oemplus = value
            Case Keys.Oemcomma
                Oemcomma = value
            Case Keys.OemMinus
                OemMinus = value
            Case Keys.OemPeriod
                OemPeriod = value
            Case Keys.Oem2
                Oem2 = value
            Case Keys.OemQuestion
                OemQuestion = value
            Case Keys.Oem3
                Oem3 = value
            Case Keys.Oemtilde
                Oemtilde = value
            Case Keys.Oem4
                Oem4 = value
            Case Keys.OemOpenBrackets
                OemOpenBrackets = value
            Case Keys.OemPipe
                OemPipe = value
            Case Keys.Oem5
                Oem5 = value
            Case Keys.OemCloseBrackets
                OemCloseBrackets = value
            Case Keys.Oem6
                Oem6 = value
            Case Keys.OemQuotes
                OemQuotes = value
            Case Keys.Oem7
                Oem7 = value
            Case Keys.Oem8
                Oem8 = value
            Case Keys.Oem102
                Oem102 = value
            Case Keys.OemBackslash
                OemBackslash = value
            Case Keys.ProcessKey
                ProcessKey = value
            Case Keys.Packet
                Packet = value
            Case Keys.Attn
                Attn = value
            Case Keys.Crsel
                Crsel = value
            Case Keys.Exsel
                Exsel = value
            Case Keys.EraseEof
                EraseEof = value
            Case Keys.Play
                Play = value
            Case Keys.Zoom
                Zoom = value
            Case Keys.NoName
                NoName = value
            Case Keys.Pa1
                Pa1 = value
            Case Keys.OemClear
                OemClear = value
            Case Keys.KeyCode
                KeyCode = value
            Case Keys.Shift
                Shift = value
            Case Keys.Control
                Control = value
            Case Keys.Alt
                Alt = value
            Case Keys.Modifiers
                Modifiers = value
        End Select
    End Sub
End Structure
